package com.meichis.yndms.adapter;

import android.content.Context;

import com.meichis.mcsappframework.adapter.recyclerview.CommonAdapter;
import com.meichis.mcsappframework.adapter.recyclerview.base.ViewHolder;
import com.meichis.mcsappframework.utils.ArithUtil;
import com.meichis.yndms.R;
import com.meichis.yndms.model.SalesRank;

import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-29 10:25
 */
public class SalesRankStaffAdapter extends CommonAdapter<SalesRank> {


    public SalesRankStaffAdapter(Context context, int layoutId, List<SalesRank> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, SalesRank salesRank, int position) {
        holder.setText(R.id.tv_rank, String.valueOf(position+1));
        holder.setText(R.id.tv_staff, salesRank.getUserName());
        holder.setText(R.id.tv_salesMoney, ArithUtil.roundStr(salesRank.getSalesMoney(), 0));
        holder.setText(R.id.tv_sales, String.valueOf(salesRank.getSalesIQuantity()));

        if (position == 0){
            holder.setVisible(R.id.tv_rank,false);
            holder.setVisible(R.id.iv_rank,true);
        }else {
            holder.setText(R.id.tv_rank, String.valueOf(position+1));
        }

        if (position % 2 == 0) {
            if (position == mDatas.size() - 1) {
                holder.setBackgroundRes(R.id.ll_item, R.drawable.shape_fillet_bottom_solid_white);
            } else {
                holder.setBackgroundRes(R.id.ll_item, R.color.white);
            }
        } else {
            if (position == mDatas.size() - 1) {
                holder.setBackgroundRes(R.id.ll_item, R.drawable.shape_fillet_bottom_solid_theme_light);
            } else {
                holder.setBackgroundRes(R.id.ll_item, R.color.theme_light);
            }
        }


    }
}
